package com.crm.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crm.entity.Role;
import com.crm.service.impl.RoleServiceImpl;

@RestController
@RequestMapping("role")
public class RoleController {

	@Autowired
	private RoleServiceImpl serviceImpl;
	@GetMapping
	
	public Object getRole(Role r,Integer page,Integer limit) {
		
		return serviceImpl.getRoleByFenYe(r, page, limit);
	}
	
	@PostMapping	
	@RequiresPermissions("role:add")
	public Object addRole(Role r) {
		
		return serviceImpl.addRole(r);
	}
	
	@PutMapping
	@RequiresPermissions("role:update")
	public Object updateRole(Role r) {
		
		return serviceImpl.updateRole(r);
	}
	@DeleteMapping
	@RequiresPermissions("role:del")
	public Object deleteRole(Integer id) {		
		return serviceImpl.deleteRole(id);
	}
	@PostMapping("/commit")
	//@RequiresPermissions("role:manageRole_Module")
	public Object manageRole_Module(Integer rid,String mids) {
		
		return serviceImpl.manageRole_Module(rid, mids);
	}
}
